﻿@{
    ViewBag.Title = "LoginPage";
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>登录系统</title>
    <link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.2/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.2/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.2/demo.css">
    <script type="text/javascript" src="~/Content/jquery-easyui-1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="~/Content/jquery-easyui-1.4.2/jquery.easyui.min.js"></script>
    <script>
        $(function () {
            //绑定键盘按下事件
            $(document).keypress(function (e) {
                var e = event || window.event || arguments.callee.caller.arguments[0];
                //回车键事件
                if (e && e.keyCode == 13) {   //keyCode=13是回车键
                    //$("#btn_Search").click();
                    js_method();
                }
            });
        });

        function js_method() {
            var role;
            //var loginRole = document.getElementsByName("radRole");
            var loginRole = "2";
            for (var i = 0; i < loginRole.length; i++) {
                if (loginRole[i].checked) {
                    role = loginRole[i].value;
                }
            }
            var acc = $('#AccNum').textbox('getValue');//通过easyui组件方法取值
            if (acc) {
                var passwd = $('#AccPW').textbox('getValue');
                if (passwd) {
                    $.ajax({
                        //要用post方式
                        type: "POST",
                        //方法所在页面和方法名
                        url: "/Login/Check",
                        data: "{acc:'" + acc + "',pwd:'" + passwd + "',role:'" + role + "'}", //带参数的,参数名称abc,参数“111”
                        //date:"{}",//没有参数的初始化
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (data) {
                            if (data == "1") {
                                window.location.href = "/Home/Index";
                            } else {
                                $.messager.alert("友情提示", "用户名或密码错误！");
                            }
                        }
                    });
                } else {
                    $.messager.alert("友情提示", "请输入密码");
                }
            } else {
                $.messager.alert("友情提示", "请输入账号");
            }
        }

        function loadTopWindow() {
            if (window.top != null && window.top.document.URL != document.URL) {
                window.top.location = document.URL; //这样就可以让登陆窗口显示在整个窗口了
            }
        }

    </script>
</head>
<body onload="loadTopWindow()">
    <!--面板start-->
    <div style="position: absolute; top: 50%; left: 50%; margin: -160px 0 0 -200px;">
        <div class="easyui-panel" title="请登录系统" style="width: 400px; padding: 30px 70px 20px 70px;">
            <div style="margin-bottom: 10px">
                <input id="AccNum" class="easyui-textbox" style="width: 100%; height: 40px; padding: 12px" data-options="prompt:'Username',iconCls:'icon-man',iconWidth:38">
            </div>
            <div style="margin-bottom: 20px">
                <input id="AccPW" class="easyui-textbox" type="password" style="width: 100%; height: 40px; padding: 12px" data-options="prompt:'Password',iconCls:'icon-lock',iconWidth:38">
            </div>
            <div style="margin-bottom: 20px">
                @*<input type="checkbox" checked="checked">
                    <span>Remember me</span>*@
                @*<input id="userT" name="radRole" type="radio" value="1" checked /><label for="userT">一般用户</label>
                    <input id="operT" name="radRole" type="radio" value="2" /><label for="userT">操作员</label>*@
            </div>
            <div>
                <a href="javascript:js_method();" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" style="padding: 5px 0px; width: 100%;">
                    <span style="font-size: 14px;">Login</span>
                </a>
            </div>
            @*<div >
                    <a href="~/Register/fill_mobile" class="easyui-linkbutton"  data-options="toggle:true,group:'g2',plain:true">注册</a>
                </div>*@
        </div>
    </div>
    <!--窗体end-->

    <script type="text/javascript">
        document.getElementById("AccNum").value = "";
        document.getElementById("AccPW").value = "";
    </script>

</body>
</html>
